# -*- conding:UTF-8 -*-

'''
@ Project: P8_lxpro_7.7
@ File: create_flask.py
@ Author: 罗婷
@ Date：2022/7/7 11:49

'''
from flask import Flask
from flask_cors import CORS

from app.auth_app import auth_bp
from app.common_app import common_bp
from app.contact_app import contact_bp
from app.group_app import group_bp
from app.upload_app import upload_bp
from app.user_app import user_bp
from common.models import db
from common.utils.token_authxxx import check_auth


def create_flask_app(info):
    app = Flask(__name__)
    app.config.from_object(info)
    CORS(app)
    db.init_app(app)
    # TODO 钩子函数
    app.before_request(check_auth)
    app.register_blueprint(auth_bp)
    app.register_blueprint(common_bp)
    app.register_blueprint(contact_bp)
    app.register_blueprint(user_bp)
    app.register_blueprint(upload_bp)
    app.register_blueprint(group_bp)


    app.before_request(check_auth)
    return app
